package com.java1412.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author java1412
 * @create 2021-07-19 13:47
 */
@Configuration
@EnableSwagger2     // 开启swagger2
// @ComponentScan(basePackages = "com.java1412.controller")
public class Swagger2Config {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .apis(RequestHandlerSelectors.basePackage("com.java1412.controller"))
                //.paths(PathSelectors.any())
                .build().apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("java1412项目接口文档")
                .description("java1412项目接口测试")
                .version("0.0.1")
                .contact(new Contact("java1412", "http://www.java1412.com", "1017070824"))
                .termsOfServiceUrl("")
                .license("")
                .license("")
                .build();
    }
}
